from pydantic import BaseModel, Field
import uuid
from typing import Optional, List
from datetime import datetime

class UiCaseFilters(BaseModel):
    name__like: Optional[str] = Field(default=None, alias="name")
    parent_id__in: Optional[str] = Field(default=None, alias="parent_id")

class UiCaseBase(BaseModel):
    name: str   # 用例名称
    type: int  #类型
    # module_name: str        # 模块名称
    parent_id: Optional[uuid.UUID] = None  # 父用例ID

class UiCaseIn(UiCaseBase):
    pass


class UiCaseOut(UiCaseBase):
    id: uuid.UUID           # 用例ID
    sys_create_datetime: datetime    # 创建时间
    sys_update_datetime: datetime    # 更新时间
    sys_effect_datetime: datetime    # 生效时间
    sys_expire_datetime: Optional[datetime] = None  # 失效时间
    sys_flag: bool          # 标记
    sort: int               # 排序
    children: List["UiCaseOut"] = []  # 子用例

    class Config:
        from_attributes = True


class UiCaseStepIn(BaseModel):
    id: Optional[uuid.UUID]
    stepDescription: str
    assertion:str
    caseId:Optional[uuid.UUID]




# StepIn 和 StepOut 用于表示每个步骤
class StepIn(BaseModel):
    step_description: str
    assertion: str
    order: int
    assert_type: str=''




class StepOut(StepIn):
    id: str

    class Config:


        orm_mode = True

# CaseIn 用于表示包含多个步骤
class CaseIn(BaseModel):
    case_id: str
    steps: List[StepIn]





# CaseOut 用于表示返回的步骤集合
class CaseOut(BaseModel):
    case_id: str
    steps: List[StepOut]

    class Config:
        orm_mode = True



# class UiCaseStep

